////
////  SNCompilePlanViewController.m
////  ZhuoxinAgriculture
////
////  Created by stone on 16/12/25.
////  Copyright © 2016年 stone. All rights reserved.
////
//
//#import "SNPlanListViewController.h"
//#import "SNCompilePlanPesticideCell.h"
//#import "SNCompilePlanMoreCell.h"
//#import "SNCompilePlanFertilizerCell.h"
//#import "SNCompilePlanSummaryCell.h"
//#import "SNCompilePlanSeedCell.h"
//
//#import "SNCompilePlanSectionHeaderView.h"
//#import "SNCompilePlanOtherCell.h"
//#import "SNNewCompilePlanViewController.h"
//#import "SNCompilePlanTopView.h"
//#import "Masonry.h"
//#import "SNCompilePlanCell.h"
//static SNProductionPlanListResult *__productionPlanListResultCopy;
//@interface SNNewCompilePlanViewController ()<UITableViewDataSource,UITableViewDelegate,SNCompilePlanPesticideCellDelegate,SNCompilePlanFertilizerCellDelegate>
///** normalView */
//@property (weak, nonatomic) UIView * bottomView;
///** mmButton */
//@property(weak, nonatomic) UIButton * saveButton;
///** tableView */
//@property (nonatomic,weak) UITableView * tableView;
///** View */
//@property (weak, nonatomic)  SNCompilePlanTopView *topView;
//
///** copy列表模型 */
//@property (nonatomic,strong) SNProductionPlanListResult * productionPlanListResultCopy;
///** firstLoad */
//@property (nonatomic, assign,getter=isFirstLoad) BOOL firstLoad;
//@end
//
//@implementation SNNewCompilePlanViewController
//+ (SNProductionPlanListResult *)getProductionPlanListResultCopy{
//    return __productionPlanListResultCopy;
//}
//+ (void)setProductionPlanListResultCopy:(SNProductionPlanListResult *)productionPlanListResultCopy{
//    __productionPlanListResultCopy = productionPlanListResultCopy;
//}
//- (void)viewWillAppear:(BOOL)animated {
//    [super viewWillAppear:animated];
//    if (self.isFirstLoad) {
//        self.firstLoad = NO;
//    }else{
//        
//        self.productionPlanListResultCopy = __productionPlanListResultCopy;
//        
//        [self.tableView reloadData];
//    }
//}
//- (void)viewDidAppear:(BOOL)animated {
//    [super viewDidAppear:animated];
//}
//- (void)viewWillDisappear:(BOOL)animated {
//    [super viewWillDisappear:animated];
//}
//- (void)viewDidDisappear:(BOOL)animated {
//    [super viewDidDisappear:animated];
//}
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    self.firstLoad = YES;
//    self.navigationItem.title = @"编辑生产计划";
//    self.automaticallyAdjustsScrollViewInsets = NO;
//    self.view.backgroundColor = kNormalBackgroundColor;
//    //sn_note:=========  ============================ stone 🐳 ===========/
//    NSLog(@"%@",self.productionPlanListResult.pestList);
//    NSLog(@"%@",self.productionPlanListResultCopy.pestList);
//    
//    
////    self.productionPlanListResultCopy = self.productionPlanListResult.copy;
////    NSLog(@"%@ | productionPlanListResult = %p",self.class,self.productionPlanListResult);
//    
//    
//    __productionPlanListResultCopy = self.productionPlanListResult.copy;
//    self.productionPlanListResultCopy = __productionPlanListResultCopy;
//    //    NSLog(@"self.productionPlanListResultCopy = %p",self.productionPlanListResultCopy.createTime);
//    //    NSLog(@"self.productionPlanListResult = %p",self.productionPlanListResult.createTime);
//    
//    // Do any additional setup after loading the view, typically from a nib.
//    [self addBottomView];
//    [self addTopView];
//    
//    [self.view layoutIfNeeded];
//    [self addTableView];
//}
//- (void)addTableView
//{
//    /** y坐标 */
//    CGFloat y = CGRectGetMaxY(self.topView.frame)+17;
//    /** 高度 tableView */
//    CGFloat height = self.view.bounds.size.height - y - self.bottomView.frame.size.height;
//    /** 样式 tableView */
//    UITableViewStyle tableViewStyle = UITableViewStyleGrouped;
//    
//    CGRect frame = CGRectMake(0, y, self.view.bounds.size.width, height);
//    
//    UITableView * tableView = [[UITableView alloc] initWithFrame:frame style:tableViewStyle];
//    self.tableView = tableView;
//    tableView.delegate = self;
//    tableView.dataSource = self;
//    tableView.backgroundColor = kNormalBackgroundColor;
//    [self setupInit:tableView];
//    
//    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
//    //    tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
//    //    tableView.separatorColor = [UIColor greenColor];
//    [self.view addSubview:tableView];
//    
//    [self addObserver];
//    [self addRequest];
//}
//- (void)addBottomView
//{
//    UIView * bottomView = ({
//        UIView * view = [[UIView alloc] init];
//        
//        view.backgroundColor = kNormalBackgroundColor;
//        // [self addSubview:view];
//        [self.view addSubview:view];
//        
//        [view mas_makeConstraints:^(MASConstraintMaker * make) {
//            make.left.mas_equalTo(self.view.mas_left).offset(0);
//            make.right.mas_equalTo(self.view.mas_right).offset(0);
//            make.bottom.mas_equalTo(self.view.mas_bottom).offset(0);
//            make.height.mas_equalTo(48);
//        }];
//        
//        UIView *splitLineView = [[UIView alloc] init];
//        splitLineView.backgroundColor = kSplitLineViewColor;
//        [view addSubview:splitLineView];
//        [splitLineView mas_makeConstraints:^(MASConstraintMaker * make) {
//            make.left.mas_equalTo(view.mas_left).offset(0);
//            make.right.mas_equalTo(view.mas_right).offset(0);
//            make.top.mas_equalTo(view.mas_top).offset(0);
//            make.height.mas_equalTo(1);
//        }];
//        
//        view;
//    });
//    self.bottomView = bottomView;
//    
//    
//    
//    UIButton * saveButton = ({
//        UIButton * button = [[UIButton alloc] init];
//        button.layer.cornerRadius = 4;
//        button.layer.masksToBounds = YES;
//        [button setTitle:@"全部保存" forState:UIControlStateNormal];
//        [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//        
//        button.titleLabel.font = [UIFont systemFontOfSize:15];
//        
//        [button setBackgroundImage:[SNUtils imageWithString:@"67B245"] forState:UIControlStateNormal];
//        
//        [button addTarget:self action:@selector(saveButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
//        
//        [bottomView addSubview:button];
//        
//        [button mas_makeConstraints:^(MASConstraintMaker * make) {
//            make.left.mas_equalTo(bottomView.mas_left).offset(30);
//            make.right.mas_equalTo(bottomView.mas_right).offset(-30);
//            make.top.mas_equalTo(bottomView.mas_top).offset(8);
//            make.bottom.mas_equalTo(bottomView.mas_bottom).offset(-8);
//        }];
//        
//        button;
//    });
//    
//    self.saveButton = saveButton;
//}
//-(void)saveButtonClicked:(UIButton *)sender {
//    NSLog(@"%s", __func__);
//    //TODO: 保存, 模型赋值
//    NSLog(@"%@ | productionPlanListResult = %p",self.class,self.productionPlanListResult);
//    NSLog(@"%@",self.productionPlanListResult.pestList);
//    NSLog(@"%@",self.productionPlanListResultCopy.pestList);
//    
//    SNProductionPlanListModel * productionPlanListModel =  [SNPlanListViewController getProductionPlanListModel];
//    SNProductionPlanListResult * resultCopy = self.productionPlanListResultCopy;
//    SNProductionPlanListResult * resultOriginal = productionPlanListModel.result[self.indexPath.section];
//    
//    //---
//    resultOriginal.fertList = resultCopy.fertList;
//    resultOriginal.landList = resultCopy.landList;
//    resultOriginal.pestList = resultCopy.pestList;
//    resultOriginal.createTime = resultCopy.createTime;
//    resultOriginal.cropType = resultCopy.cropType;
//    resultOriginal.custNo = resultCopy.custNo;
//    resultOriginal.fullName = resultCopy.fullName;
//    resultOriginal.operatorName = resultCopy.operatorName;
//    resultOriginal.planName = resultCopy.planName;
//    resultOriginal.planNo = resultCopy.planNo;
//    resultOriginal.plantingArea = resultCopy.plantingArea;
//    resultOriginal.seedBrand = resultCopy.seedBrand;
//    resultOriginal.seedManu = resultCopy.seedManu;
//    resultOriginal.seedPerUse = resultCopy.seedPerUse;
//    resultOriginal.seedPrice = resultCopy.seedPrice;
//    resultOriginal.seedTotal = resultCopy.seedTotal;
//    resultOriginal.startTime = resultCopy.startTime;
//    resultOriginal.status = resultCopy.status;
//    resultOriginal.year = resultCopy.year;
//    resultOriginal.fertTotal = resultCopy.fertTotal;
//    resultOriginal.plantTypes = resultCopy.plantTypes;
//    resultOriginal.cropTypeName = resultCopy.cropTypeName;
//    //---
//    
//    [SNPlanListViewController setProductionPlanListModel:productionPlanListModel];
//    
//    [self.navigationController popViewControllerAnimated:YES];
//}
//- (void)addTopView
//{
//    SNCompilePlanTopView *topView = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([SNCompilePlanTopView class]) owner:nil options:nil] lastObject];
//    self.topView = topView;
//    topView.plantingDecisionMakerResult = self.plantingDecisionMakerResult;
//    [self.view addSubview:topView];
//    
//    [topView mas_makeConstraints:^(MASConstraintMaker * make) {
//        make.left.mas_equalTo(self.view.mas_left).offset(12);
//        make.right.mas_equalTo(self.view.mas_right).offset(-12);
//        make.top.mas_equalTo(self.view.mas_top).offset(64);
//    }];
//}
//
////sn_note:========= tableView ============================ stone 🐳 ===========/
//#pragma mark - <addRequest>
//- (void)addRequest {
//    // addRequest
//}
//#pragma mark - <addObserver>
//- (void)addObserver {
//    // addObserver
//}
//- (void)dealloc {
//    NSLog(@"%@ %s %@",[self class], __func__ , @"im dying");
//}
///** 初始化 tableView */
//- (void)setupInit:(UITableView *)tableView
//{
//    //MARK: - 设置tableHeaderView
//    //    {
//    //        UIView * tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 17)];
//    //        tableHeaderView.backgroundColor = kNormalBackgroundColor;
//    //        tableView.tableHeaderView = tableHeaderView;
//    //    }
//    
//    //MARK: - 注册
//    {
//        /** xib 注册cell */
//        registerForCellFromeNib(tableView,SNCompilePlanCell);
//        registerForCellFromeNib(tableView,SNCompilePlanOtherCell);
//        registerForCellFromeNib(tableView,SNCompilePlanSeedCell);
//        registerForCellFromeNib(tableView,SNCompilePlanSummaryCell);
//        registerForCellFromeNib(tableView,SNCompilePlanFertilizerCell);
//        registerForCellFromeNib(tableView,SNCompilePlanMoreCell);
//        registerForCellFromeNib(tableView,SNCompilePlanPesticideCell);
//        
//        /** class 注册cell */
//        //  registerForCellFromeClass(tableView,UITableViewCell);
//        
//        /** xib 注册 headerSection */
//        registerForHeaderFooterViewFromeNib(tableView,SNCompilePlanSectionHeaderView);
//        
//        
//        /** class 注册 headerSection */
//        //    registerForHeaderFooterViewFromeClass(tableView,UITableViewHeaderFooterView);
//        
//        /** xib 注册 footerSection */
//        //    registerForHeaderFooterViewFromeNib(tableView,UITableViewHeaderFooterView);
//        /** class 注册 footerSection */
//        //    registerForHeaderFooterViewFromeClass(tableView,UITableViewHeaderFooterView);
//    }
//    //MARK: - 设置高度
//    {
//        /** header */
//        //        tableView.sectionHeaderHeight = 17;
//        tableView.estimatedSectionHeaderHeight = 100;
//        tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
//        /** cell */
//        tableView.estimatedRowHeight = 100;
//        tableView.rowHeight = UITableViewAutomaticDimension;
//        /** footer */
//        tableView.sectionFooterHeight = 17;
//        // tableView.estimatedSectionFooterHeight = 100;
//        // tableView.sectionFooterHeight = UITableViewAutomaticDimension;
//    }
//}
//
//#pragma mark - <UITableViewDataSource>
///** 组数 */
//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//    
//    return 4;
//}
///** 行数 */
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//    switch (section) {
//        case 0:
//            if (self.productionPlanListResultCopy.cropTypeName.length > 0 ) {
//                return 1;
//            }else{
//                return 0;
//            }
//        case 1:
//            if (self.productionPlanListResultCopy.seedBrand.length > 0 ) {
//                return 1;
//            }else{
//                return 0;
//            }
//        case 2:
//            return self.productionPlanListResultCopy.fertList.count+1;
//        case 3:
//            return self.productionPlanListResultCopy.pestList.count+1;
//        default:
//            return self.rowCount;
//    }
//    
//    
//}
////MARK: -
////MARK: - cell
///** cell */
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    UITableViewCell * cell = nil;
//    switch (indexPath.section) {
//        case 0:
//        {
//            SNCompilePlanSummaryCell * cellTemp = DequeueForCell(SNCompilePlanSummaryCell);
//            [cellTemp configCellWithTitle:@"概要信息" imageName:@"05-earth"];
//            cellTemp.nav = self.navigationController;
//            cellTemp.productionPlanListResult = self.productionPlanListResultCopy;
//            cell = cellTemp;
//        }
//            break;
//        case 1:
//        {
//            SNCompilePlanSeedCell * cellTemp = (SNCompilePlanSeedCell *)DequeueForCell(SNCompilePlanSeedCell);
//            [cellTemp configCellWithTitle:@"种子信息" imageName:@"05-seed"];
//            cellTemp.nav = self.navigationController;
//            cellTemp.productionPlanListResult = self.productionPlanListResultCopy;
//            cell = cellTemp;
//        }
//            break;
//        case 2:
//        {
//            if (indexPath.row == self.productionPlanListResultCopy.fertList.count) {
//                SNCompilePlanMoreCell * cellTemp = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SNCompilePlanMoreCell class])];
//                cellTemp.nav = self.navigationController;
//                cellTemp.indexPath = indexPath;
//                cell = cellTemp;
//            }else{
//                SNCompilePlanFertilizerCell * cellTemp = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SNCompilePlanFertilizerCell class])];
//                cellTemp.delegate = self;
//                NSString *title = [NSString stringWithFormat:@"肥料信息( %zd )",indexPath.row+1];
//                [cellTemp configCellWithTitle:title imageName:@"11-flow" indexPath:indexPath];
//                
//                cellTemp.productionPlanListResult = self.productionPlanListResultCopy;
//                cellTemp.nav = self.navigationController;
//                
//                cell = cellTemp;
//            }
//        }
//            break;
//        case 3:
//        {
//            if (indexPath.row == self.productionPlanListResultCopy.pestList.count) {
//                SNCompilePlanMoreCell * cellTemp = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SNCompilePlanMoreCell class])];
//                cellTemp.nav = self.navigationController;
//                cellTemp.indexPath = indexPath;
//                cell = cellTemp;
//            }else{
//                SNCompilePlanPesticideCell * cellTemp = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([SNCompilePlanPesticideCell class])];
//                cellTemp.delegate = self;
//                NSString *title = [NSString stringWithFormat:@"农药信息( %zd )",indexPath.row+1];
//                [cellTemp configCellWithTitle:title imageName:@"icon_pesticide" indexPath:indexPath];
//                cellTemp.productionPlanListResult = self.productionPlanListResultCopy;
//                
//                cellTemp.nav = self.navigationController;
//                cell = cellTemp;
//            }
//        }
//            break;
//            
//        default:
//            break;
//    }
//    
//    
//    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
//    return cell;
//}
//#pragma mark - <SNCompilePlanPesticideCellDelegate>
//- (void)deleteInfomationWithIndexPath:(NSIndexPath *)indexPath object:(NSObject *)object{
//    
//    if ([object isKindOfClass:[SNCompilePlanFertilizerCell class]]) {
//        NSMutableArray<SNProductionPlanListFertlist *> * arrM  = self.productionPlanListResultCopy.fertList.mutableCopy;
//        [arrM removeObjectAtIndex:indexPath.row];
//        self.productionPlanListResultCopy.fertList = arrM;
//        
//        [self.tableView reloadData];
//    }else if ([object isKindOfClass:[SNCompilePlanPesticideCell class]]) {
//        NSMutableArray<SNProductionPlanListPestlist *> * arrM  = self.productionPlanListResultCopy.pestList.mutableCopy;
//        [arrM removeObjectAtIndex:indexPath.row];
//        self.productionPlanListResultCopy.pestList = arrM;
//        
//        [self.tableView reloadData];
//    }
//}
//#pragma mark - <UITableViewDelegate>
///** 自定义section header */
//- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
//    
//    UITableViewHeaderFooterView * headerView = nil;
//    
//    switch (section) {
//        case 0:
//        {
//            SNCompilePlanSectionHeaderView * headerViewTemp = DequeueForHeaderFooterView(SNCompilePlanSectionHeaderView);
//            [headerViewTemp configCellWithTitle:@"概要信息" imageName:@"05-earth" productionPlanListResult:self.productionPlanListResultCopy];
//            headerViewTemp.nav = self.navigationController;
//            headerView = headerViewTemp;
//        }
//            break;
//        case 1:
//        {
//            SNCompilePlanSectionHeaderView * headerViewTemp = DequeueForHeaderFooterView(SNCompilePlanSectionHeaderView);
//            [headerViewTemp configCellWithTitle:@"种子信息" imageName:@"05-seed" productionPlanListResult:self.productionPlanListResultCopy];
//            headerViewTemp.nav = self.navigationController;
//            headerView = headerViewTemp;        }
//            break;
//        case 2:
//        {
//            SNCompilePlanSectionHeaderView * headerViewTemp = DequeueForHeaderFooterView(SNCompilePlanSectionHeaderView);
//            [headerViewTemp configCellWithTitle:@"肥料信息" imageName:@"05-fertilizer" productionPlanListResult:self.productionPlanListResultCopy];
//            headerViewTemp.nav = self.navigationController;
//            headerView = headerViewTemp;
//        }
//            break;
//        case 3:
//        {
//            SNCompilePlanSectionHeaderView * headerViewTemp = DequeueForHeaderFooterView(SNCompilePlanSectionHeaderView);
//            [headerViewTemp configCellWithTitle:@"农药信息" imageName:@"05-medicine" productionPlanListResult:self.productionPlanListResultCopy];
//            headerViewTemp.nav = self.navigationController;
//            
//            headerView = headerViewTemp;
//        }
//            break;
//            
//        default:
//            break;
//    }
//    
//    return headerView;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
//    
//    return -1;
//}
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
//    
//    return 17;
//}
///** 选中一行 */
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    NSLog(@"%s", __func__);
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//}
///** 取消 选中 */
//- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(3_0) {
//    NSLog(@"%s", __func__);
//}
///** 可编辑 */
////- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
////{
////    return YES;
////}
///** 删除样式 */
////- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
////{
////    return UITableViewCellEditingStyleDelete;
////}
///** 删除当前行 */
////- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
////
////    if (editingStyle == UITableViewCellEditingStyleDelete) {
////
////        [self.models removeObjectAtIndex:indexPath.row];
////
////        [tableView deleteRowsAtIndexPaths:@[ indexPath ] withRowAnimation:UITableViewRowAnimationLeft];
////}
//
//@end
